package com.LachesismStorm.lachesism.member.controller;

import com.LachesismStorm.lachesism.core.common.response.ResponsePage;
import com.LachesismStorm.lachesism.core.common.response.ResponseResult;
import com.LachesismStorm.lachesism.core.service.RedisService;
import com.LachesismStorm.lachesism.member.dto.UmsMemberParam;
import com.LachesismStorm.lachesism.member.service.DatingService;
import com.LachesismStorm.lachesism.member.vo.*;
import com.LachesismStorm.lachesism.member.vo.dto.*;
import com.LachesismStorm.lachesism.member.vo.param.DatingEventParam;
import com.LachesismStorm.lachesism.member.vo.param.DatingForumParam;
import com.LachesismStorm.lachesism.member.vo.param.MemberParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lachesism
 * @Date 2025-02-24 13:49
 **/

@RestController
@Api(tags = "相亲接口")
@RequestMapping("/dating")
public class DatingController {

    @Resource
    private DatingService datingService;


    @ApiOperation(value = "获取所有区域")
    @PostMapping("/getAllArea")
    public ResponseResult geAllArea() {
        List<AreaList> areaList = datingService.geAllArea();
        return ResponseResult.success(areaList, "查询成功");
    }

    @ApiOperation(value = "查询所有用户，传role：1/2来进行管理员的区分")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "UmsMemberParam", value = "用户查询条件")
    })
    @PostMapping("/getUserList")
    public ResponseResult getUserList(@RequestBody MemberParam memberParam) {
        ResponsePage<MemberDto> userList = datingService.getUserList(memberParam);
        return ResponseResult.success(userList, "查询成功");
    }

    @ApiOperation(value = "查询聊天记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "UmsMemberParam", value = "只传PageNum和PageSize")
    })
    @PostMapping("/getChatList")
    public ResponseResult getChatList(@RequestBody MemberParam memberParam) {
        ResponsePage<DatingChat> chatList = datingService.getChatList(memberParam);
        return ResponseResult.success(chatList, "查询成功");
    }

    @ApiOperation(value = "创建活动")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEvent", value = "DatingEvent")
    })
    @PostMapping("/createEvent")
    public ResponseResult createEvent(@RequestBody DatingEvent datingEvent) {
        datingService.createEvent(datingEvent);
        return ResponseResult.success(null, "创建成果");
    }

    @ApiOperation(value = "查看活动")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEventParam", value = "DatingEventParam")
    })
    @PostMapping("/getDatEventList")
    public ResponseResult getDatEventList(@RequestBody DatingEventParam datingEvent) {
        ResponsePage<DatingEvent> eventList = datingService.getDatEventList(datingEvent);
        return ResponseResult.success(eventList, "创建成果");
    }

    @ApiOperation(value = "修改活动信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEvent", value = "DatingEvent")
    })
    @PostMapping("/updateEvent")
    public ResponseResult updateEvent(@RequestBody DatingEvent datingEvent) {
        datingService.updateEvent(datingEvent);
        return ResponseResult.success(null, "修改成功");
    }

    @ApiOperation(value = "报名活动")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEventApplication", value = "DatingEventApplication")
    })
    @PostMapping("/eventApplication")
    public ResponseResult eventApplication(@RequestBody DatingEventApplication application) {
        datingService.eventApplication(application);
        return ResponseResult.success(null, "报名成功");
    }

    @ApiOperation(value = "查看报名列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEvent", value = "DatingEvent")
    })
    @PostMapping("/getEventApplicationList")
    public ResponseResult getEventApplicationList(@RequestBody DatingEvent datingEvent) {
        List<DatingEventApplication> applicationList = datingService.getEventApplicationList(datingEvent);
        return ResponseResult.success(applicationList, "查询成功");
    }

    @ApiOperation(value = "查看我的报名活动")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEventParam", value = "只传PageNum和PageSize")
    })
    @PostMapping("/getMyEventApplicationList")
    public ResponseResult getMyEventApplicationList(@RequestBody DatingEventParam datingEvent) {
        ResponsePage<DatingEventDto> applicationList = datingService.getMyEventApplicationList(datingEvent);
        return ResponseResult.success(applicationList, "查询成功");
    }

    @ApiOperation(value = "发布论坛文章")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingForum", value = "DatingForum")
    })
    @PostMapping("/publishForum")
    public ResponseResult publishForum(@RequestBody DatingForum forum) {
        datingService.publishForum(forum);
        return ResponseResult.success(null, "发布成功");
    }

    @ApiOperation(value = "查看论坛文章列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingForumParam", value = "DatingForumParam")
    })
    @PostMapping("/getForumList")
    public ResponseResult getForumList(@RequestBody DatingForumParam forum) {
        ResponsePage<DatingForum> forumList = datingService.getForumList(forum);
        return ResponseResult.success(forumList, "查询成功");
    }

    @ApiOperation(value = "查看我发布的论坛文章列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingForumParam", value = "DatingForumParam")
    })
    @PostMapping("/getMyForumList")
    public ResponseResult getMyForumList(@RequestBody DatingForumParam forum) {
        ResponsePage<DatingForum> forumList = datingService.getMyForumList(forum);
        return ResponseResult.success(forumList, "发布成功");
    }

    @ApiOperation(value = "修改论坛文章")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingForum", value = "DatingForum")
    })
    @PostMapping("/editForum")
    public ResponseResult editForum(@RequestBody DatingForum forum) {
        datingService.editForum(forum);
        return ResponseResult.success(null, "修改成功");
    }

    @ApiOperation(value = "查看文章详情")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "id")
    })
    @PostMapping("/getForumDetail")
    public ResponseResult getForumDetail(@RequestParam Integer id) {
        DatingForumDto forum = datingService.getForumDetail(id);
        return ResponseResult.success(forum, "查找成功");
    }

    @ApiOperation(value = "文章消息点赞/已点赞的则取消")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "id")
    })
    @PostMapping("/like")
    public ResponseResult like(@RequestParam Integer id) {
        datingService.like(id);
        return ResponseResult.success(null, "操作成功");
    }

    @ApiOperation(value = "查看我点赞论坛文章记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingForumParam", value = "只传PageNum和PageSize")
    })
    @PostMapping("/getMyLike")
    public ResponseResult getMyLike(@RequestBody DatingForumParam param) {
        ResponsePage<DatingForum> forumList = datingService.getMyLike(param);
        return ResponseResult.success(forumList, "查询成功");
    }

    @ApiOperation(value = "关注用户/取消")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "userId", value = "被关注人id")
    })
    @PostMapping("/follow")
    public ResponseResult follow(@RequestParam Integer userId) {
        datingService.follow(userId);
        return ResponseResult.success(null, "操作成功");
    }

    @ApiOperation(value = "查看关注用户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingForumParam", value = "只传PageNum和PageSize")
    })
    @PostMapping("/getFollowList")
    public ResponseResult getFollowList(@RequestBody DatingForumParam param) {
        ResponsePage<DatingFollow> followList = datingService.getFollowList(param);
        return ResponseResult.success(followList, "查询成功");
    }

    @ApiOperation(value = "查看消息列表")
    @PostMapping("/getMessageList")
    public ResponseResult getMessageList() {
        List<DatingMessage> messages = datingService.getMessageList();
        return ResponseResult.success(messages, "查询成功");
    }

    @ApiOperation(value = "新增评论")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingComments", value = "DatingComments")
    })
    @PostMapping("/addComment")
    public ResponseResult addComment(@RequestBody DatingComments comments) {
        datingService.addComment(comments);
        return ResponseResult.success(null, "评论成功");
    }

    @ApiOperation(value = "删除评论")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingComments", value = "DatingComments")
    })
    @PostMapping("/deleteComment")
    public ResponseResult deleteComment(@RequestBody DatingComments comments) {
        datingService.deleteComment(comments);
        return ResponseResult.success(null, "删除成功");
    }

    @ApiOperation(value = "获取文章下的评论")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "forumId", value = "文章id")
    })
    @PostMapping("/getForumComment")
    public ResponseResult getForumComment(@RequestBody DatingComments comments) {
       List<DatingCommentsDto> commentList = datingService.getForumComment(comments);
        return ResponseResult.success(commentList, "查询成功");
    }

    @ApiOperation(value = "聊天")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingChat", value = "DatingChat")
    })
    @PostMapping("/chat")
    public ResponseResult chat(@RequestBody DatingChat chat) {
        datingService.chat(chat);
        return ResponseResult.success(null, "评论成功");
    }

    @ApiOperation(value = "聊天列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "chatUserId", value = "聊天对象id")
    })
    @PostMapping("/chatList")
    public ResponseResult getChatList(@RequestParam Integer chatUserId) {
        List<DatingChat> chatList = datingService.chatList(chatUserId);
        return ResponseResult.success(chatList, "查询成功");
    }


    @ApiOperation(value = "添加脏话")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "word", value = "脏话内容")
    })
    @PostMapping("/addSwearing")
    public ResponseResult addSwearing(@RequestParam String word) {
        datingService.addSwearing(word);
        return ResponseResult.success(null, "添加成功");
    }
    @ApiOperation(value = "删除脏话")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "脏话id")
    })
    @PostMapping("/deleteSwearing")
    public ResponseResult deleteSwearing(@RequestParam Integer id) {
        datingService.deleteSwearing(id);
        return ResponseResult.success(null, "删除成功");
    }
    @ApiOperation(value = "脏话列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "DatingEventParam", value = "只传PageNum和PageSize")
    })
    @PostMapping("/swearingList")
    public ResponseResult swearingList(@RequestBody DatingEventParam param) {
        ResponsePage<DatingSwearing> swearingList =datingService.swearingList(param);
        return ResponseResult.success(swearingList, "添加成功");
    }
}
